#include <iostream>
#include <algorithm>

using namespace std;
int n;
int b[100010];

int main()
{
    cin >> n;
    int a[n + 10];
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    auto it = unique(a + 1, a + n + 1) - a - 1;
    a[0] = a[it + 1] = 0;
    //表示水平面降低到y时发生的变化
    for (int i = 1; i <= it; i++)
    {
        int x = a[i - 1], y = a[i], z = a[i + 1];
        if (x < y && z < y)
            b[y]++;
        else if (x > y && z > y)
            b[y]--;
    }
    int res = 0, sum = 0;
    for (int i = 10010; i>=1; i--)
    {
        sum += b[i];
        res = max(res, sum);
    }
    cout << res << endl;
    //system("pause");
    return 0;
}